<?php
if (!defined('STATUSNET') && !defined('LACONICA')) {
    exit(1);
}

class PinzuiPlugin extends Plugin
{
    function __construct()
    {
        parent::__construct();
    }

	function onEndShowStyles($action){
		$action->element('meta', array('name' => 'description', 'content' => common_config('site', 'description')));
		$action->element('meta', array('name' => 'keywords', 'content' => common_config('site', 'keywords')));
	}
	
	function onStartPrimaryNav($action){
    	$action->raw('<li id="nav_suibian"><a title="随便看看" href="/">随便看看</a></li>');
    }
    
	/*function onStartPersonalGroupNav($action){
    	$action->raw('<li id="nav_guangchang"><a title="贫嘴广场" href="http://pinzui.com">贫嘴广场</a></li>');
    }*/
	
	function onEndSecondaryNav($action){
    	$action->raw('<li><a href="/doc/plus" target="_blank">更多玩法</a></li><li><a href="http://blog.pinzui.com" target="_blank">官方博客</a></li><li><a href="http://www.shhrpx.com/" title="上海人力资源培训网" target="_blank">上海人力资源培训网</a></li><li><a href="http://wiki.pinzui.com/" title="Wiki" target="_blank">Wiki</a></li><li><a href="http://wiki.pinzui.com/index.php/API" title="Wiki" target="_blank">API</a></li>');
    }
	function onEndPrimaryNav($action){
    	$action->raw('<li id="nav_plus"><a title="更多方法使用微博客" href="/doc/plus">更多玩法</a></li><li id="nav_forum"><a title="微博客程序下载" href="http://forum.pinzui.com/">论坛</a></li>');
    }
    
    /*function onEndShowSections($action){
    	$html = '<p>火贫：<a class="more" href="https://addons.mozilla.org/zh-CN/firefox/addon/13830" target="_blank">点击进入下载页面</a><br />
    	（Fireforx插件）
    	</p>';
    	$action->raw($html);
		$action->raw('<p>
<a title="绑定QQ" target="_blank" href="http://pinzui.com/local/Qq/qq.php">绑定QQ</a></p>');
    }*/
	//如果没有登录则显示登录的表单
	/*function onStartShowSections($action)
    {
		if(!isset($_SESSION['userid'])&&($action->args['action']=='public')){
			$action->elementStart('form', array('method' => 'post',
											   'id' => 'form_login',
											   'class' => 'form_settings',
											   'action' => common_local_url('login')));
			$action->elementStart('fieldset');
			$action->element('legend', null, _('Login to site'));
			$action->elementStart('ul', 'form_data');
			$action->elementStart('li');
			$action->input('nickname', _('Nickname'));
			$action->elementEnd('li');
			$action->elementStart('li');
			$action->password('password', _('Password'));
			$action->elementEnd('li');
			$action->elementStart('li');
			$action->checkbox('rememberme', _('Remember me'), false);
			$action->elementEnd('li');
			$action->elementEnd('ul');
			$action->submit('submit', _('Login'));
			$action->element('input', array('type' => 'button',
                                      'id' => 'register',
                                      'onclick' =>'location.href="/main/register"' ,
                                      'class' => 'submit',
                                      'value' => _('Register'),
                                      'title' => _('Register')));
			$action->hidden('token', common_session_token());
			$action->elementEnd('fieldset');
			$action->elementEnd('form');
			$action->elementStart('p');
			$action->elementEnd('p');
		}
    }*/
	
	function onEndShowSections($action){
		$html = '<div class="section"><h2>官方QQ群</h2>贫嘴官方交流群：74377748<br />
    	贫嘴官方技术群：103151678<br />
    	<h2>更多玩法</h2>
    	<a href="http://pinzui.com/local/Qq/qq.php">绑定QQ</a><br />
    	WAP版: m.pinzui.com<br />
    	<a href="http://pinzui.com/doc/plus">Twhirl</a><br />
    	<a href="http://blog.pinzui.com/?p=36">Twidroid@Android</a><br />
    	<a href="http://blog.pinzui.com/?p=32">火贫－Firefox插件</a><br />
    	<a href="http://fanfou.pinzui.com" target="_blank">饭否搬家到贫嘴</a><sup style="color:red">New</sup>
    	</div>';
    	$action->raw($html);
		/*$args = $action->args;
    	if($args['action']=='public'){
			$rsslink = 'http://pinzui.com/rss';
		}
		if(isset($args['nickname'], $args['p']) && !empty($args['p'])){
			$rsslink = 'http://pinzui.com/'.$args['p'].'/rss';
		}
		
    	if ($rsslink!='') {
    		$html = '
    		<div id="subs" class="section">
    		<h2>更多订阅方式</h2>
    		<script type="text/javascript" src="http://china-addthis.googlecode.com/svn/trunk/addthis.js" charset="UTF-8"></script><span class="addthis_org_cn"><a href="http://addthis.org.cn/share/" title="收藏&amp;分享"><img src="http://addthis.org.cn/images/a3.gif" alt="分享家:Addthis中国" align="absmiddle" /></a></span><br />
    		<script type="text/javascript" src="http://china-addthis.googlecode.com/svn/trunk/addfeed.js" charset="UTF-8"></script><span class="addfeed_cn"><a href="'.$rsslink.'" title="订阅我吧"><img src="http://addfeed.cn/images/f1.gif" alt="分享家:Addfeed" align="absmiddle" /></a></span>
    		</div>';
    		$action->raw($html);
    		
    		<table>
			<tr><td><a href="http://inezha.com/add2?url='.$rsslink.'" title="此博客内容更新用IM提醒我" target="_blank"><img src="/theme/pinzuinew/images/rss/anothr.gif" alt="用IM提醒我内容更新"/></a></td></tr>
			<tr><td><a href="http://mail.qq.com/cgi-bin/feed?u='.$rsslink.'" title="订阅到QQ邮箱" target="_blank"><img src="/theme/pinzuinew/images/rss/qqmail.png" alt="订阅到QQ邮箱"/></a></td></tr>
			<tr><td><a href="http://www.xianguo.com/subscribe.php?url='.$rsslink.'" title="订阅到鲜果阅读器" target="_blank"><img src="/theme/pinzuinew/images/rss/xianguo.png" alt="订阅到鲜果阅读器"/></a></td></tr>
			<tr><td><a href="http://fusion.google.com/add?feedurl='.$rsslink.'" title="订阅到Google阅读器" target="_blank"><img src="/theme/pinzuinew/images/rss/google.png" alt="订阅到Google阅读器"/></a></td></tr>
			<tr><td><a href="http://www.zhuaxia.com/add_channel.php?url='.$rsslink.'" title="订阅到抓虾阅读器" target="_blank"><img src="/theme/pinzuinew/images/rss/zhuaxia.png" alt="订阅到抓虾阅读器"/></a></td></tr></table>	
    	}*/
    }
	function onEndShowScripts($action)
    {
    	$js_top='var anon_html = $("#anon_notice").html();
    	var form_html = $("#form_notice").html();
    	if(anon_html==null && form_html==null)
    	{$("#site_notice").hide();$("#header").css("height","60px");}';
        $action->elementStart('script', array('type' => 'text/javascript'));
        $action->raw($js_top);
        $action->elementEnd('script');
        
        $js = _('<script language="javascript" type="text/javascript" src="http://js.users.51.la/2992516.js"></script>');
        $action->elementStart('span', array('style' => 'display:none;'));
        $action->raw($js);
        $action->elementEnd('span');
        $jsfuc = '<SCRIPT LANGUAGE="JavaScript">
<!--
function AddFavorite(sURL, sTitle){
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
function SetHome(obj,vrl){
        try{
               obj.style.behavior="url(#default#homepage)";obj.setHomePage(vrl);
        }
        catch(e){
                if(window.netscape) {
                        try {
                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                        }
                        catch (e) {
                                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为true,双击即可。");
                        }
                        var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
                        prefs.setCharPref("browser.startup.homepage",vrl);
                 }
        }
}
//-->
</SCRIPT>';
        $action->raw($jsfuc);
    }
}
